package com.visualexpress.messager.email;

import javax.mail.MessagingException;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMultipart;

public class MailByText extends TextMailInfo implements ConstructMail {

	private String mimeType = "text/plain";
	
	public String getMimeType() {
		return mimeType;
	}

	public void setMimeType(String mimeType) {
		this.mimeType = mimeType;
	}

	@Override
	public MimeMultipart constructMailBody() {
		MimeBodyPart bodyPart = new MimeBodyPart();
		MimeMultipart multiPart = new MimeMultipart();
		try {
			bodyPart.setContent(mailBody, mimeType + "; charset=gbk");
			multiPart.addBodyPart(bodyPart);
		} catch (MessagingException e) {
			return null;
		}
		return multiPart;
	}

	@Override
	public String constructSubject() {
		return mailSubject;
	}

}
